package com.cloudxingkong.dianyinke.NewTeacher.Utils;

import android.os.CountDownTimer;
import android.widget.Button;

/**
 * Created by 云星空科技 on 2016/3/25.
 */
public class TimerUtils extends CountDownTimer{
    private Button btnGetYzm;

    /**
     * 初始化
     * @param millisInFuture 总时长
     * @param countDownInterval 计时间隔
     * @param btnGetYzm  操作的UI
     */
    public TimerUtils(long millisInFuture, long countDownInterval, Button btnGetYzm) {
        super(millisInFuture, countDownInterval);
        this.btnGetYzm = btnGetYzm;

    }
    /**
     * 计时过程
     * @param millisUntilFinished
     */
    @Override
    public void onTick(long millisUntilFinished) {
        btnGetYzm.setClickable(false);
        btnGetYzm.setText(millisUntilFinished/1000+"秒后重发");
    }
    /**
     * 计时结束
     */
    @Override
    public void onFinish() {
        btnGetYzm.setText("重新发送验证码");
        btnGetYzm.setClickable(true);
    }
}
